package com.guoxin.thread.extthread.t13forprint;

public class MyThread2 extends Thread {

    @Override
    public void run() {
        try {
            for (int i = 0; i < 100000; i++) {
                if (this.isInterrupted()) {
                    System.out.println("已经是停止状态了！我要退出了！");
                    throw new InterruptedException();
                }
                System.out.println("i=" + (i + 1));
            }
            System.out.println("我被输出了，如果此代码是for又继续运行，线程并未停止");
        } catch (InterruptedException e) {
            System.out.println("进入MyThread2.java 类 run 方法中的catch了！");
            e.printStackTrace();
        }

    }
}
